/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package gruppe1projekt.GUILayer;

import gruppe1projekt.GUILayer.Interfaces.IInteraction;
import gruppe1projekt.GUILayer.Interfaces.IValidatable;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import javax.swing.JPanel;

/**
 *
 * @author Moulde
 */
public class BaseWindow extends JPanel implements IValidatable, IInteraction, ActionListener
{
    protected boolean InteractionHappened = false;
    private int ID;
    protected boolean RequiresLogin;
    
    public BaseWindow()
    {
        ChangeSize(500, 500);
        RequiresLogin = true;
    }

    public void ChangeSize(int width, int height)
    {
        Dimension pnlSize = new Dimension(width, height);

        setBounds(0, 0, width, height);
        setMinimumSize(pnlSize);
        setMaximumSize(pnlSize);
        setSize(pnlSize);
        setPreferredSize(pnlSize);
    }

    public boolean RequiresLogin()
    {
        return RequiresLogin;
    }

    public void actionPerformed(ActionEvent e)
    {
        //Nothing
    }

    public int getID()
    {
        return ID;
    }

    protected void setID(int ID)
    {
        this.ID = ID;
    }

    public boolean IsValid()
    {
        //Vil først blive brugt når den bliver nedarvet, derfor er det ligemeget hvad den returnerer.
        return false;
    }

    public boolean HasInteraction()
    {
        return InteractionHappened;
    }

    protected boolean isDouble(String value)
    {
        try
        {
            double parsed = Double.parseDouble(value);
        }
        catch (Exception e)
        {
            return false;
        }

        return true;
    }

    protected boolean isLong(String value)
    {
        try
        {
            long parsed = Long.parseLong(value);
        }
        catch (Exception e)
        {
            return false;
        }
        return true;
    }

    protected boolean isInteger(String value)
    {
        try
        {
            int parsed = Integer.parseInt(value);
        }
        catch (Exception e)
        {
            return false;
        }
        return true;
    }

    protected void insertPanel(JPanel container, JPanel panel)
    {
        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(container);
        container.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
                jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel3Layout.createSequentialGroup().addComponent(panel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)));

        jPanel3Layout.setVerticalGroup(
                jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel3Layout.createSequentialGroup().addComponent(panel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)));
    }
}
